package com.example.cargetter.config;

/**
 * 写配置类，将yml文件中的端口注入类对象中。
 */

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "udp")
public class UdpConfig {

    /**
     * 与嵌入式通信的udp 监听 端口
     */
    private static Integer listeningPort;

    /**
     * 与嵌入式通信的udp 发送 端口
     */
    private static Integer sendingPort;

    @Value("${udp.listeningPort}")
    public void setListeningPort(Integer listeningPort) {
        UdpConfig.listeningPort = listeningPort;
    }

    @Value("${udp.sendingPort}")
    public void setSendingPort(Integer sendingPort) {
        UdpConfig.sendingPort = sendingPort;
    }

    public static Integer getListeningPort() {
        return listeningPort;
    }

    public static Integer getSendingPort() {
        return sendingPort;
    }
}

